package cc.wsyw126.java.mongoDB.Utils;

import com.mongodb.MongoClient;
import com.mongodb.client.MongoCollection;
import com.mongodb.client.MongoDatabase;
import org.bson.Document;

/**
 * Created by junpeng.yang on 17/1/9.
 */
public class MongoDBJDBC {
    public static MongoDatabase getMongoDB() {
        MongoDatabase mongoDatabase = null;
        try {
            // 连接到 mongodb 服务
            MongoClient mongoClient = new MongoClient("localhost", 27017);
            // 连接到数据库
            mongoDatabase = mongoClient.getDatabase("bpm_garen_system");
            System.out.println("Connect to database successfully");
        } catch (Exception e) {
            System.err.println(e.getClass().getName() + ": " + e.getMessage());
        }
        return mongoDatabase;
    }
}
